package org.ainlolcat.ctp.guice;

import com.google.inject.Guice;
import com.google.inject.Injector;
import com.google.inject.Module;
import org.ainlolcat.ctp.guice.config.LocalConfigurationModule;

/**
 * Created by IntelliJ IDEA.
 * User: ain
 * Date: 06.09.12
 * Time: 11:24
 * To change this template use File | Settings | File Templates.
 */
public class Loader {
    private static Injector injector;
    private static Module[] modules;

    static {
        modules = new Module[]{new LocalConfigurationModule()};
        injector = Guice.createInjector(modules);
    }
    
    public static <T> T get(Class<T> clazz){
        return injector.getInstance(clazz);
    }
    
    public static void setConfiguration(Module... newmodules){
        modules = newmodules;
        injector =  Guice.createInjector(modules);
    }
    
}
